/**
 * Copyright (c) 2002-2012 旭鸣信息
 * All rights reserved. 
 * File：FrontUserAddrService.java
 * History: Dec 27, 2012: Initially created, liuzhi.
 */
package com.xteam.ecsystem.service.front;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xteam.ecsystem.dao.IFrontUserAddrDao;
import com.xteam.ecsystem.entities.BaseDistributeRegion;
import com.xteam.ecsystem.entities.BaseReceiveAddress;

/**
 * 前端用户-收货人地址服务层。
 * @author liuzhi
 */
@Service
public class FrontUserAddrService {
	
	@Autowired
	private IFrontUserAddrDao userAddrDao;
	
	/**
	 * 获得收货人地址数量
	 * @author liuzhi Mar 12, 2013
	 * @param braMember
	 * @return
	 */
	public int getUserAddrNums(String braMember){
		return this.userAddrDao.getUserAddrNums(braMember);
	}
	
	/**
	 * 新增或编辑收货人地址
	 * @author liuzhi Mar 18, 2013
	 * @param bra
	 * @param braId
	 * @return
	 */
	public String saveOrUpdateObj(BaseReceiveAddress bra, String braId){
		return this.userAddrDao.saveOrUpdateObj(bra, braId);
	}

	/**
	 * 获得用户收货地址列表
	 * @author liuzhi Mar 12, 2013
	 * @param braMember
	 * @return
	 */
	public List<BaseReceiveAddress> getUserAddrs(String braMember){
		return this.userAddrDao.getUserAddrs(braMember);
	}
	
	/**
	 * 取消用户默认收货地址
	 * @author liuzhi Mar 14, 2013
	 * @param braMember
	 */
	public void saveCancelUserDefAddr(String braMember){
		this.userAddrDao.saveCancelUserDefAddr(braMember);
	}
	
	/**
	 * 设置用户默认收货地址
	 * @author liuzhi Mar 14, 2013
	 * @param braId
	 */
	public void saveUserDefAddr(String braId){
		this.userAddrDao.saveUserDefAddr(braId);
	}
	
	/**
	 * 根据区域编号获得区域信息
	 * @author liuzhi Mar 13, 2013
	 * @param regionId
	 * @return BaseDistributeRegion
	 */
	public BaseDistributeRegion getRegionInfo(String regionId){
		return this.userAddrDao.getRegionInfo(regionId);
	}
	
	/**
	 * 删除用户收货地址
	 * @author liuzhi Mar 14, 2013
	 * @param braId
	 */
	public void deleteUserAddr(String braId){
		this.userAddrDao.deleteUserAddr(braId);
	}
	
	/**
	 * 获得区域列表
	 * @author liuzhi Mar 14, 2013
	 * @param bdrId
	 * @param bdrParent
	 * @return
	 */
	public List<BaseDistributeRegion> getRegionList(String bdrId, String bdrParent){
		return this.userAddrDao.getRegionList(bdrId, bdrParent);
	}
	
	/**
	 * 
	 * 根据用户ID获取收货信息
	 * @author ls
	 * @param memberId
	 * @return
	 */
	public BaseReceiveAddress getReceiverInfo(String memberId) {
		return userAddrDao.getReceiverInfo(memberId);
	}

	/**
	 * 
	 * 有无收货地址
	 * @author ls
	 * @return
	 */
	public boolean hasAddress(String memberId) {
		return userAddrDao.hasAddress(memberId);
	}

	/**
	 * 根据收货地址编号获得对应的收货地址信息
	 * @author liuzhi Mar 18, 2013
	 * @param addrId
	 * @return
	 */
	public BaseReceiveAddress getReceiverInfoById(String addrId) {
		return this.userAddrDao.getReceiverInfoById(addrId);
	}

}
